<template>
  <parentSelect
    ref="controlInst"
    getUrl="/base/supplier/listForSelect"
    @change="_change"
    :getQuery="_getQuery"
    :value="value"
    :valueDisplay="valueDisplay"
    :disabled="disabled"
    :popWidth="popWidth"
  />
</template>

<script>
import parentSelect from '@/components/custom/bus/select/parentSelect.vue'

export default {
  desc: '供应商选择',
  name: 'spSelect',
  components: {
    parentSelect
  },
  props: {
    /**
     * @Description：true 中心仓库
     */
    value: {
      type: String,
      default: () => null
    },
    /**
     * @Description：显示名称
     */
    valueDisplay: {
      type: String,
      default: () => ''
    },
    /**
     * @Description：true: 禁用
     */
    disabled: {
      type: Boolean,
      default: () => false
    },
    /**
     * @Description：true: 禁用
     */
    flagDisabled: {
      type: Boolean,
      default: () => false
    },
    /**
     * @Description：true: 禁用
     */
    popWidth: {
      type: Number,
      default: () => 250
    }
  },
  watch: {
  },
  data() {
    return {
    }
  },
  computed: {
  },
  methods: {
    // 选中项改变
    _change(selectItem) {
      this.$emit('change',  selectItem)
    },

    // 查询条件
    _getQuery() {
      let wrapper = this.$newWrapper()
      if (global.strings.isNotBlank(this.flagDisabled)) {
        wrapper.eq('flagDisabled', this.flagDisabled)
      }
      return wrapper
    },

    // 实例
    getInst() {
      return this.$refs.controlInst
    },

    // 聚焦搜索框
    focus() {
      this.getInst().focus()
    },
  },
}
</script>
